package com.shangguan.springboot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName: GobalConfig
 * @Description:
 * @Author: 一尘
 * @Date: 2020 年 03 月 07 23:01
 * @Version 1.0
 */
@Configuration
public class GlobalConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/welcome").setViewName("welcome");
        registry.addViewController("/unicode").setViewName("unicode");
        /*registry.addViewController("/member-list").setViewName("member-list");
        registry.addViewController("/member-list1").setViewName("member-list1");
        registry.addViewController("/member-del").setViewName("member-del");
        registry.addViewController("/order-list").setViewName("order-list");
        registry.addViewController("/admin-list").setViewName("admin-list");
        registry.addViewController("/admin-role").setViewName("admin-role");
        registry.addViewController("/admin-cate").setViewName("admin-cate");
        registry.addViewController("/admin-rule").setViewName("admin-rule");*/
        registry.addViewController("/error").setViewName("error");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
      //跨域处理
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("*").allowedOrigins("Access-Control-Allow-Origin");
    }
}
